<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>相册管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
    <style type="text/css">
    </style>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
                    <div class="layui-tab-content">
                        <form class="layui-form" action="${ctx}/photo/photoproject/list.do" id="myForm"
                              method="post">
                            <input type="hidden" name="timeStatus" id="status" value="${input.timeStatus}"/>
                            <input type="hidden" name="pageNo" id="pageNo"/>
                            <div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">项目名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="projectName" autocomplete="off" class="layui-input"
                                                       value="${projectName}"
                                                       placeholder="请输入相册名称"
                                                >
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">发布者</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="member" autocomplete="off"
                                                       class="layui-input" value="${member}"
                                                       placeholder="请输入查询相册发布者"
                                                >
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label
                                                class="search-form-lable">排序方式</label>
                                            <div class="layui-input-inline">
                                                <select name="softType">
                                                    <option value="">默认</option>
                                                    <option value="1" ${softType == 1 ? 'selected="selected"' : ''}>浏览次数</option>
                                                    <option value="2" ${softType == 2 ? 'selected="selected"' : ''}>照片数量</option>
                                                </select>
                                            </div>
                                        </li>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item"><label class="search-form-lable">发布时间</label>
                                            <div class="check-btn-inner" id="timeType">
                                                <a id="all" href="javascript:void(0);"
                                                   onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                                <input type="hidden" name="timeType" value="${input.timeType}"/>
                                            </div>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="createStart"
                                                           value="${input.createStart}" placeholder="开始日">
                                                </div>
                                                -
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="createEnd"
                                                           value="${input.createEnd}" placeholder="截止日">
                                                </div>
                                            </div>
                                        </li>
                                        <li class="form-item-inline">
                                            <div class="sub-btns">
                                                <a class="layui-btn layui-btn-danger"
                                                   href="javascript:submitFunction('#myForm')">查询</a>
                                                <a class="layui-btn layui-btn-normal"
                                                   href="javascript:resetFunction('#myForm')">重置</a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </form>
                        <div class="c-time-list-content">
                            <ul id="view">
                                <c:if test="${page.totalCount == 0}">
                                    <div class="f16 tc mt15">还没有数据，请点击右上角的“创建相册”，发布和编辑相册</div>
                                </c:if>
                                <c:forEach var="project" items="${projectList}">
                                    <li>
                                        <div class="detail-content">
                                            <a href="${ctx}/photo/photoproject/toForm.do?id=${project.id}"
                                               class="act-logo common-img"
                                            >
                                                <img src="<c:if test="${project.pic != null}">${project.pic}?imageMogr2/auto-orient/crop/200x150</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                            </a>
                                            <div class="detail">
                                                <div class="act-title title f18 text-ellipsis">${project.name}</div>
                                                <div>
                                                    <p class="act-price">
                                                        <c:if test="${not empty project.startTime and not empty project.endTime}">
                                                            <span style="margin-right: 10px;">
                                                            活动时间：
                                                            <fmt:formatDate value="${project.startTime}" pattern="yyyy-MM-dd HH:mm"/>~<fmt:formatDate
                                                                    value="${project.endTime}" pattern="yyyy-MM-dd HH:mm"/></span>
                                                        </c:if>
                                                        <c:if test="${empty project.startTime and not empty project.endTime}">
                                                            <span style="margin-right: 10px;">
                                                            活动时间：
                                                            ?~<fmt:formatDate
                                                                    value="${project.endTime}" pattern="yyyy-MM-dd HH:mm"/></span>
                                                        </c:if>
                                                        <c:if test="${not empty project.startTime and empty project.endTime}">
                                                            <span style="margin-right: 10px;">
                                                            活动时间：
                                                            <fmt:formatDate value="${project.startTime}" pattern="yyyy-MM-dd HH:mm"/>~?</span>
                                                        </c:if>
                                                        <span style="margin-right: 10px;">照片数量：
                                                            <b class="active-red">${project.imgNum}</b>张</span>
                                                    </p>
                                                    <p class="act-price">
                                                        <c:if test="${not empty project.place}">
                                                            <span style="margin-right: 10px;">活动地点： ${project.place}</span>
                                                        </c:if>
                                                        <span style="margin-right: 10px;">浏览次数： <b class="active-red">${project.viewNum}</b>次</span>
                                                        <span style="margin-right: 10px;">操作次数： <b class="active-red">${project.operateNum}</b>次</span>
                                                    </p>
                                                    <c:if test="${not empty project.circleId}">
                                                        <p class="act-price">
                                                            关联通讯录：
                                                            <a href="${ctx}/circle/member/list.do?id=${project.circleId}">
                                                                <span style="margin-right: 10px;">
                                                                    <b class="active-red">${project.circleName}</b>
                                                                </span>
                                                            </a>
                                                        </p>
                                                    </c:if>
                                                    <p class="act-price">
                                                        <span style="margin-right: 10px;">合作商：
                                                            <b class="active-red">${project.memberName}</b>
                                                        </span>
                                                        <span style="margin-right: 10px;">创建时间：
                                                            <fmt:formatDate value="${project.createDate}" pattern="yyyy-MM-dd HH:mm"/>
                                                        </span>
                                                    </p>
                                                </div>
                                                <div class="opts-btns tb-opts" style="width:475px">
                                                    <div class="comm-opts">
                                                        <a class="qr-btn" href="javascript:txz.openQrDialog({
                                                            title:'扫码二维码可预览分享',
                                                            detailList:[{
                                                                title:'相册详情二维码',
                                                                url:'${project.qrcodeUrl}',
                                                                link:''
                                                            }]
                                                        })">二维码</a>
                                                        <a href="${ctx}/photo/album/list.do?photosId=${project.id}">
                                                            <i class="iconfont icon-peoplelist btn-icon"></i>
                                                            相册管理</a>
                                                        <a href="${ctx}/photo/photoproject/toForm.do?id=${project.id}">
                                                            <i class="iconfont icon-edit btn-icon"></i> 编辑</a>
                                                        <a href="javascript:txz.deleteObject('确定要删除吗？','${ctx}/photo/photoproject/delete.do?projectId=${project.id}');">
                                                            <i class="iconfont icon-delete btn-icon"></i> 删除
                                                        </a>
                                                        <a href="javascript:createQrCode('${project.id}')">生成二维码</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                </c:forEach>
                            </ul>
                            <div id="page_content" class="page-container"></div>
                        </div>
                    </div>

        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">

    <%--showActive('${input.createStart}', '${input.createEnd}', '#timeType');--%>
    txz.initHeader({
        nav:[{
            name: '活动相册管理',
            curr: true
        }],
        info:'<span class="f12">共<b>${page.totalCount}</b>条记录',
        btns:[{
            name: '创建相册',
            icon: 'add',
            href: '${ctx}/photo/photoproject/toForm.do'
        }]
    });
    $(function () {
        // 加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['laytpl', 'laypage', 'element', 'laydate'], function () {
            var laytpl = layui.laytpl, laydate = layui.laydate, laypage = layui.laypage, element = layui.element;
            element.on('tab(type)', function (data) {
                if (data.index == 0) {
                    $('#status').val(0);
                    $('#myForm').submit();
                }
                else if (data.index == 1) {
                    $('#status').val(1);
                    $('#myForm').submit();
                }
            });

            // 查询开始日期
            var start = {
                elem: 'input[name=s_start]'
            };

            var end = {
                elem: 'input[name=s_end]'
            };
            laydate.render(start);
            laydate.render(end);

            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })

    // 生成项目二维码
    function createQrCode(photoId) {
        layer.confirm('确定要生成相册二维码？', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            $.post("${ctx}/photo/photoproject/checkXcxQrCode.do", {
                photoId: photoId
            }, function (data) {
                if (data.success) {
                    util.layerMsgSuccess("生成成功", function () {
                        window.location.reload();
                    })
                } else {
                    util.layerMsgError("生成失败")
                }
            });
        });
    }
</script>
</body>
</html>